This document describes the AppleScripts that are included in the DiskExpress Pro package and provides some guidelines for writing your own AppleScripts for use with DiskExpress Pro.
Contents
AppleScripts included with DiskExpress Pro
- Archive Files
- Clear Selected Files
- Get Disk Info
- Get File Info
- List Files
- Optimize Disk
- Optimize Disk Files
- Optimize Selected Files
- Set File Priority
- Set Selected Files
Writing Your Own AppleScripts For DiskExpress Pro
Dictionary for the DiskExpress Extension Suite
List of Errors Returned by the DiskExpress Extension Suite
AppleScripts included with DiskExpress Pro
Archive Files
The Archive Files AppleScript is designed to allow you to move or copy files based on two types of criteria. You may choose to archive files based on their priority or on the last date they were accessed. Archiving by priority allows you to archive all files with the priority you specify. For example, you could choose to archive all dormant files on your disk. Archiving by last access date allows you to archive all files which were last accessed prior to a date that you specify. For example, you could choose to archive all files which have not been used in the last six months.
In addition to allowing you to select the archiving criteria, the script lets you choose whether or not to delete items from the source disk once they have been archived, and gives you the option of replacing files in the destination that have the same name as files being archived.
You may use this script by double-clicking it or by dragging source folders or disks to the script. Successful completion of the script is signaled by two system beeps.
Clear Selected Files
The Clear Selected Files AppleScript clears the list of files selected for optimization for the indicated disk. The list of files selected for optimization contains the names of the files that will be optimized during a Selected Files optimization. For more information on the Selected Files optimization method refer to the DiskExpress Pro manual.
You may use this script by double-clicking it or by dragging disk icons to the script. Successful completion of the script is signaled by two system beeps.
Get Disk Info
The Get Disk Info AppleScript displays a dialog containing DiskExpress Pro information about the selected disk. The information displayed includes: the disk name, its current optimization index, the capacity and free space available on the disk, the last date on which the disk’s free space was erased, the date and method used for the most recent file optimization, the last date on which the disk’s directory was verified, and the date of the most recent verification of the disk’s media.
You may use this script by double-clicking it or by dragging disk icons to the script.
Get File Info
The Get File Info AppleScript displays a dialog containing DiskExpress Pro information about the selected file. The information displayed includes: the file name, whether or not the file is fragmented or anchored, the file’s priority, and the last time the file was accessed.
You may use this script by double-clicking it or by dragging file icons to the script.
List Files
The List Files AppleScript creates a text document listing files based on three types of criteria. You may choose to list files based on their priority, based on the last date they were accessed, or based on being selected for selected files optimization. Listing files by priority allows you to create a list of all files with the priority you specify. For example, you could choose to list all active files on your disk. Listing files by last access date allows you to create a list of all files which were last accessed prior to a date that you specify. For example, you could choose to list all files which have not been used in the last six months.
You may use this script by double-clicking it or by dragging source folders or disks to the script. Successful completion of the script is signaled by two system beeps.
Optimize Disk
The Optimize Disk AppleScript tells DiskExpress Pro to optimize one or more disks according to their current settings in the Disk Options tab of the DiskExpress Pro control panel. You will be asked whether or not DiskExpress Pro should ignore user activity and input/output activity during the optimization, and whether or not DiskExpress Pro should shut down your computer after it has finished optimizing.
You may use this script by double-clicking it or by dragging disk icons to the script. This script makes no changes to the current disk options as set in the DiskExpress Pro control panel.
Due to the way compiled AppleScripts behave, executing this script will cause optimization to stop if the script is located on the same volume as the one being optimized. There are two work-arounds. The first option is to execute this script once and then lock this script. The second option is to uncheck the “Do not wait for optimization to finish” option when prompted.
Optimize Disk Files
The Optimize Disk Files AppleScript tells DiskExpress Pro to perform only the Optimize Files activity on one or more disks. The Verify Media, Verify Directory and Erase Free Space activities are not performed regardless of their current settings in the Disk Options tab of the DiskExpress Pro control panel. You will be asked to specify the optimization method to be used, the means by which DiskExpress Pro should notify you in case of an error, whether or not DiskExpress Pro should ignore user activity and input/output activity during the Optimize Files activity, and whether or not DiskExpress Pro should shut down your computer after it has finished optimizing the files.
You may use this script by double-clicking it or by dragging disk or file icons to the script. Dragging file icons to the script specifies those files as the files to be optimized for a Selected Files optimization and replaces the current list of files selected for selected files optimization as set in the DiskExpress Pro control panel.
Due to the way compiled AppleScripts behave, executing this script will cause optimization to stop if the script is located on the same volume as the one being optimized. There are two work-arounds. The first option is to execute this script once and then lock this script. The second option is to uncheck the “Do not wait for optimization to finish” option when prompted.
Optimize Selected Files
The Optimize Selected Files AppleScript tells DiskExpress Pro to perform the Optimize Files activity using the Selected Files method on the indicated disk or disks. The script tells DiskExpress Pro to ignore user activity and input/output activity during the Optimize Files activity and tells DiskExpress Pro not to shut down the computer afterwards. The script displays a message when the Optimize Files activity is completed.
This script is used by dragging the selected files to the script. Running this script replaces the current list of files selected for selected files optimization as set in the DiskExpress Pro control panel.
Due to the way compiled AppleScripts behave, executing this script will cause optimization to stop if the script is located on the same volume as the one being optimized. There are two work-arounds. The first option is to execute this script once and then lock this script. The second option is to uncheck the “Do not wait for optimization to finish” option when prompted.
Set File Priority
The Set File Priority AppleScript allows you to set the priority of one or more files. Once you set a file’s priority, DiskExpress Pro leaves the file with the priority you select. If you no longer wish to force a file to have a specific priority, choose the “Let DiskExpress Pro assign the priority” option in the Set File Priority dialog.
You may use this script by double-clicking it to set the priority of a single file, or by dragging folder or disk icons to the script to set the priority of all files contained in those folders and disks. Successful completion of the script is signaled by two system beeps.
Set Selected Files
The Set Selected Files AppleScript allows you to designate which files will be optimized during a Selected Files optimization. You will be asked whether the indicated files should be added to the list of files selected for optimization or if the files should replace the current list of files selected for optimization.
To use this script, drag the selected files to the script. Running this script changes the current list of files selected for selected files optimization as set in the DiskExpress Pro control panel. Successful completion of the script is signaled by two system beeps.
Writing Your Own AppleScripts For DiskExpress Pro
The best way to learn about writing your own AppleScripts for DiskExpress Pro is to modify one of the scripts that comes with the product. For example, you might want to modify the Optimize Disk script so that it always optimizes without sensitivity and without waiting instead of asking you about optimization options.
In addition to examining the included AppleScripts, you should review the AppleScript dictionary for the DiskExpress® Pro Extension. You can view the dictionary by opening the Script Editor application, choosing Open Dictionary from the File menu, then selecting the DiskExpress® Pro Extension within the Extensions folder.
When writing your own AppleScripts for DiskExpress Pro, remember that all commands sent to DiskExpress and all information you wish to get from DiskExpress must be inside a tell application block. For example:
tell application "DiskExpress® Pro Extension"
optimize startup disk
end tell
Notice that the application being sent the commands is the DiskExpress® Pro Extension.
As a final suggestion, AppleScript limitations make it inadvisable to issue AppleScript commands that will return a very large number of items. For example, avoid asking for every file of the entire contents of a disk that holds tens of thousands of files. At best the request will take a very long time to process. At worst the request will never be successfully completed at all due to the AppleScript limitations. When specifying the entire contents of a disk, use a test that will return a reasonable number of items. For example, returning every fragmented file of the entire contents of a disk.
An expanded listing of the DiskExpress® Pro Extension AppleScript dictionary is shown below for your reference.
Dictionary for the DiskExpress Extension Suite
optimize: Optimize the specified disk(s)
optimize reference -- the disks to optimize (a single disk or a list of disks)
[sensitivity boolean] -- Should DiskExpress ignore user and i/o activity during optimization? Default is true.
[shut down boolean] -- Should DiskExpress shut down the computer after optimizing? Default is false.
[waiting boolean] -- Wait until optimization is completed before executing the rest of the script? Default is true.
optimize files: Perform the "Optimize Files" activity on the specified disk(s)
optimize files reference -- the disks to optimize (a single disk or a list of disks)
[method split method/packed method/quick method/selected files method/free space method/unknown method] -- specifies the file optimization method to use. Default is split method.
[files reference] -- specifies a list of files to optimize when using the selected files method of optimization. If the files parameter is not passed and the selected files optimization method is used, DiskExpress optimizes the files currently selected for optimization on the disk. Default is an empty list.
[reporting no reporting / flash menu icon / open control panel] -- specifies the manner in which DiskExpress should report errors which occur during the optimization. Default is no reporting.
[sensitivity boolean] -- Should DiskExpress ignore user and i/o activity during optimization? Default is true.
[shut down boolean] -- Should DiskExpress shut down the computer after optimizing? Default is false.
[waiting boolean] -- Wait until optimization is completed before executing the rest of the script? Default is true.
stop optimize: Stop the current optimization
stop optimize
compute optimization index: Compute the optimization index(es) for the specified disk(s)
compute optimization index reference -- the disks to index (a single disk or a list of disks)
[sensitivity boolean] -- Should DiskExpress ignore user and i/o activity during indexing? Default is true.
[waiting boolean] -- Wait until indexing is completed before executing the rest of the script? Default is true.
Class application: An application program
Plural form:
applications
Elements:
disk by ID, by numeric index, by name, as a range of elements, satisfying a test
item by ID, by numeric index, by name, as a range of elements, satisfying a test
Properties:
frontmost boolean [r/o] -- Is this the frontmost application?
name string [r/o] -- the name of the application
version version [r/o] -- the version of the application
current operation no operation /optimize operation / analyze operation / index operation [r/o] -- the current operation being performed on any disk
enabled boolean -- Is DiskExpress on? (Controls the On/Off radio buttons in the Optimization tab of the DiskExpress control panel.)
monitor all disks boolean -- Should DiskExpress monitor all eligible disks? (Controls the Monitor All checkbox in the Disk Options tab of the DiskExpress control panel.)
optimization activity sensitivity no sensitivity / low sensitivity / medium sensitivity / high sensitivity -- sensitivity to i/o during optimizations (Controls the Input/Output Sensitivity slider in the Preferences dialog of the DiskExpress control panel.)
optimization scheduling boolean -- Should DiskExpress run scheduled optimizations? (Controls the On/Off radio buttons for Scheduled Optimizations in the Disk Options tab of the DiskExpress control panel.)
read and write verification boolean -- Should DiskExpress verify data while reading and writing disks during optimizations? (Controls the Verify Reads and Writes check box in the Preferences dialog of the DiskExpress control panel.)
schedule only when charger connected boolean -- Should DiskExpress run scheduled optimizations only when charger is connected? (Controls the Schedule only when on AC adapter check box in the Preferences dialog of the DiskExpress control panel.)
startup disk reference [r/o] -- the startup disk
Class disk: A disk
Plural form:
disks
Elements:
file by ID, by numeric index, by name, as a range of elements, satisfying a test
folder by ID, by numeric index, by name, as a range of elements, satisfying a test
item by ID, by numeric index, by name, as a range of elements, satisfying a test
Properties:
capacity unsigned integer [r/o] -- the total number of bytes (free or used) on the disk
ejectable boolean [r/o] -- Can the media be ejected (floppies, CD's, and so on)?
entire contents reference [r/o] -- the entire contents of the disk, including the contents of its folders (Can be an unmanageably large list for disks containing many items.)
free space unsigned integer [r/o] -- the number of free bytes left on the disk
id integer [r/o] -- an id that identifies the disk to the operating system
local volume boolean [r/o] -- Is the media a local volume (as opposed to a file server)?
name string -- the name of the disk
startup boolean [r/o] -- Is the disk the boot disk?
current operation no operation /optimize operation / analyze operation / index operation [r/o] -- the current operation being performed on the disk
erase free space date date [r/o] -- the date on which the free space on the disk was last erased
last operation no operation /optimize operation / analyze operation / index operation [r/o] -- the last operation performed on the disk
last operation result integer [r/o] -- the result of the last operation performed on the disk
last optimization index unsigned integer [r/o] -- the last computed optimization index for the disk (To determine the current optimization index, first use the compute optimization index command to force the index to be computed now.)
last optimize files method split method / packed method / quick method / selected files method / free space method / unknown method [r/o] -- the method last used to optimize files on the disk
optimization index date date [r/o] -- the date on which the optimization index for the disk was last computed
optimize files date date [r/o] -- the date on which files were last optimized for the disk
verify directory date date [r/o] -- the date on which the disk's directory was last verified
verify media date date [r/o] -- the date on which the disk's media was last verified
Class file: A file
Plural form:
files
Properties:
container reference [r/o] -- the container of the file
creator type type class -- the OSType identifying the application that created the file
file type type class -- the OSType identifying the type of data contained in the file
id integer [r/o] -- an id that identifies the file to the operating system
in system folder boolean [r/o] -- Is the file in the system folder? (Is true if the file is in the System folder or any folder within the System folder.)
locked boolean [r/o] -- Is the file locked?
name string -- the name of the file
visible boolean [r/o] -- Is the file visible?
access count unsigned integer [r/o] -- the number or recent accesses to the file
access date date [r/o] -- the date on which the file was last accessed
anchored boolean [r/o] -- Is the file anchored?
fragmented boolean [r/o] -- Is the file fragmented?
priority no priority / active priority / sporadic priority / dormant priority / special priority -- the activity priority of the file
selected boolean [r/o] -- Is the file selected for selected files optimization?
Class folder: A folder
Plural form:
folders
Elements:
file by ID, by numeric index, by name, as a range of elements, satisfying a test
folder by ID, by numeric index, by name, as a range of elements, satisfying a test
item by ID, by numeric index, by name, as a range of elements, satisfying a test
Properties:
container reference [r/o] -- the container of the folder
entire contents reference [r/o] -- the entire contents of the folder, including the contents of its folders (Can be an unmanageably large list for folders containing many items.)
id integer [r/o] -- an id that identifies the folder to the operating system
in system folder boolean [r/o] -- Is the folder in the system folder?
name string -- the name of the folder
visible boolean [r/o] -- Is the folder visible?
Class item: An item
Plural form:
items
List of Errors Returned By the DiskExpress Extension Suite
Error
number Error message
1101 DiskExpress is busy performing another activity and cannot process this request.
1102 Verification was stopped because the disk was removed from the desktop or ejected.
1103 Optimization was stopped because the disk was removed from the desktop or ejected.
1104 Optimization was stopped because the disk was modified.
1105 DiskExpress found bad blocks during media verification.
1108 DiskExpress received a stop optimize event.
1110 Another copy of DiskExpress with the same serial number is already in use.
1111 An unexpected error occurred.
1113 An unexpected error occurred.
1114 An unexpected error occurred.
1115 An unexpected error occurred.
1116 Optimization was stopped due to a conflict with a System Extension or an incompatibility with the current System Software.
1123 The charger was disconnected while performing a scheduled optimization.
1127 Indexing was stopped because the disk was removed from the desktop or ejected.
1128 Indexing was stopped because the disk was modified.
1133 DiskExpress is turned off.
1134 Due to an error, the DiskExpress Pro Extension was not loaded completely.
1135 A required resource is missing. DiskExpress Pro may be damaged. Please reinstall from your original diskette.
1137 Directory verification was stopped because the disk was removed from the desktop or ejected.
1138 Directory verification was stopped because the disk was modified.
1141 Erase free space was stopped because the disk was removed from the desktop or ejected.
1142 Erase free space was stopped because the disk was modified.
1147 DiskExpress found directory errors during directory verification.
1148 DiskExpress found directory warnings during directory verification.
1151 DiskExpress is turned off and must be turned on by the DiskExpress Pro control panel.
1155 An operation was requested on a non Mac OS Standard (HFS) disk.